package com.seuic.hnjiningposapp.hnapps.util;

/**
 * 转换返回的 利率  金额
 */
public class GetMoneyLvUtils {
    /**
     * 获取 利率
     *
     * @param LLSting
     * @return
     */
    public static String getLv(String LLSting) {
        String ll = "";

        String text1 = LLSting.substring(2);

        String llfont = text1.substring(0, 1);

        String llqueen = text1.substring(1).replaceAll("0+$", "");
        if (llqueen.equals("")) {
            ll = llfont + "%";
        } else {
            ll = llfont + "." + llqueen + "%";
        }

        return ll;
    }

    /**
     * 获取输入的金额  有小数点操作
     *
     * @return
     */
    public static String getInputMoney(String inputMoney) {
        String money = "";
        if (!inputMoney.contains(".")) {
            money = inputMoney + ".00";
        } else {
            String moneys[] = inputMoney.split("\\.");
            if (moneys[1].length() == 2) {
                //如果小数点后位长度是2
                money = inputMoney;
            } else {
                money = inputMoney + "0";
            }
        }
        return money;
    }


    //获取金额
    public static String getMoney(String MSting) {
        String money = "";
        if (MSting.equals("000000000000000")) {
            money = "0.00";
        } else {


            //去掉0
            String AvlBalance = MSting.replaceFirst("^0*", "");
            if (AvlBalance.length() == 1) {
                money = "0.0" + AvlBalance;
            } else {
                //截取得到后两位
                String AvlBalance2 = AvlBalance.substring(AvlBalance.length() - 2, AvlBalance.length());
                //截掉后两位
                String Balance = AvlBalance.substring(0, AvlBalance.length() - 2);
                if (Balance.equals("")) {
                    money = "0." + AvlBalance2;
                } else {
                    money = Balance + "." + AvlBalance2;
                }
            }

        }

        return money;
    }

    //获取序号   如 0001；
    public static String getNum(String numsrt) {
        String num = "";

        if (numsrt.length() == 1) {
            num = "000" + numsrt;
        } else if (numsrt.length() == 2) {
            num = "00" + numsrt;
        } else if (numsrt.length() == 3) {
            num = "0" + numsrt;
        } else if (numsrt.length() == 4) {
            num = numsrt;
        }
        return num;
    }


    /**
     * 获取币种 活期明细
     *
     * @param typenum
     * @return
     */
    public static String getMoneyType(String typenum) {
        String type = "";
        if (typenum.equals("01")) {
            type = "人民币";
        } else if (typenum.equals("14")) {
            type = "美元";
        } else if (typenum.equals("33")) {
            type = "欧元";
        } else if (typenum.equals("13")) {
            type = "港币";
        } else if (typenum.equals("12")) {
            type = "英镑";
        } else if (typenum.equals("27")) {
            type = "日元";
        }
        return type;
    }

    /**
     * 获取币种 子账户
     *
     * @param typenum
     * @return
     */
    public static String getZzhMoneyType(String typenum) {
        String type = "";
        if (typenum.equals("01")) {
            type = "人民币";
        } else if (typenum.equals("02")) {
            type = "外币折欧元";
        } else if (typenum.equals("03")) {
            type = "外币折人民币";
        } else if (typenum.equals("13")) {
            type = "港币";
        } else if (typenum.equals("12")) {
            type = "英镑";
        } else if (typenum.equals("15")) {
            type = "瑞士法郎";
        } else if (typenum.equals("14")) {
            type = "美元";
        }
        return type;
    }

    /**
     * 获取时间  传入 20330922184741
     *
     * @param timessing
     * @return
     */
    public static String gettime(String timessing) {
        String time = "";
        if (timessing.equals("")) {
            time = "——";
        } else {
            String year = timessing.substring(0, 4);
            String mont = timessing.substring(4, 6);
            String day = timessing.substring(6, 8);

            String hour = timessing.substring(8, 10);
            String minute = timessing.substring(10, 12);
            String second = timessing.substring(12, 14);
            time = year + "-" + mont + "-" + day + " " + hour + ":" + minute + ":" + second;
        }

        return time;
    }


    public static String gettimeHour(String timessing) {
        String time = "";
        if (timessing.equals("")) {
            time = "——";
        } else {
            String hour = timessing.substring(0, 2);
            String minute = timessing.substring(2, 4);
            String second = timessing.substring(4, 6);


            time = hour + ":" + minute + ":" + second;
        }

        return time;
    }

    /**
     * 获取时间  传入 20330922
     *
     * @param timessing
     * @return
     */
    public static String gettimeNohour(String timessing) {

        String time = "";
        if (timessing.equals("")) {
            time = "——";
        } else {
            String year = timessing.substring(0, 4);
            String mont = timessing.substring(4, 6);
            String day = timessing.substring(6, 8);
            time = year + "-" + mont + "-" + day;
        }

        return time;
    }

    /**
     * 特殊业务返回账户状态
     *
     * @param num //全部0,理财中1,已结息未入账2,已结息已入账3
     * @return
     */
    public static String getSpType(String num) {
        String type = "";
        if (num.equals("0")) {
            type = "全部";
        } else if (num.equals("1")) {
            type = "理财中";
        } else if (num.equals("2")) {
            type = "已结息未入账";
        } else if (num.equals("3")) {
            type = "已结息已入账";
        } else {
            type = num;
        }
        return type;
    }


    /**
     * 子账户查询  获取账户状态
     *
     * @param tv
     * @return
     */
    public static String getAccType(String tv) {
        String type = "";
        if (tv.equals("0")) {
            type = "正常";
        } else if (tv.equals("1")) {
            type = "销户";
        } else if (tv.equals("2")) {
            type = "没收";
        } else if (tv.equals("3")) {
            type = "上缴";
        } else if (tv.equals("4")) {
            type = "存单存折标识";
        } else if (tv.equals("5")) {
            type = "挂出";
        } else if (tv.equals("6")) {
            type = "冲正";
        } else if (tv.equals("6")) {
            type = "账户移出";
        }
        return type;
    }


}
